home *** CD-ROM | disk | FTP | other *** search
- /* Copyright (c) 1987 Michael E. Connick */
-
- #include <String.h>
- #include <stdio.h>
-
- UpdateNodeList()
- {
- char nFile[256], dFile[256], record[513], nodeLine[513], *ptr1;
- char command, number[20], extension[10], outFile[256];
- int counter, i;
- FILE *nfp, *dfp, *ofp;
-
- if(message("Select nodediff file.") == FALSE)
- {
- return;
- }
- if(getfile("TEXT", dFile) == FALSE)
- return;
- if((ptr1 = strchr(dFile, '.')) == NULL)
- {
- message("Invalid nodediff file selected");
- return;
- }
- strcpy(extension, ptr1);
- if((dfp = fopen(dFile,"rb")) == NULL)
- {
- message("UpdateNodeList - Unable to open nodediff file.");
- return;
- }
- if(message("Select nodelist file to be updated.") == FALSE)
- {
- return;
- }
- if(getfile("TEXT", nFile) == FALSE)
- return;
- strcpy(outFile, nFile);
- if((nfp = fopen(nFile,"rb")) == NULL)
- {
- message("UpdateNodeList - Unable to open nodelist file.");
- return;
- }
- if((ofp = fopen("templist","wb")) == NULL)
- {
- message("UpdateNodeList - Unable to open nodelist file.");
- return;
- }
- fgets(record,512,dfp);
- fgets(nodeLine,512,nfp);
- if(strcmp(record, nodeLine) != 0)
- {
- message("Incorrect nodelist/nodediff combination");
- return;
- }
- fseek(nfp, 0L, 0);
- while(fgets(record,512,dfp) != NULL)
- {
- if((ptr1 = strchr(record, '\r')) != NULL)
- *ptr1 = '\0';
- if(strlen(record) == 0)
- continue;
- ptr1 = record;
- if(*ptr1 == 0x0a)
- ptr1++;
- if(strlen(ptr1) == 0)
- continue;
- command = *ptr1++;
- strcpy(number, ptr1);
- counter = atoi(number);
- if(command == 'D')
- {
- for(i = 0; i < counter; i++)
- {
- rotateCursor();
- fgets(nodeLine,512,nfp);
- }
- }
- else if(command == 'C')
- {
- for(i = 0; i < counter; i++)
- {
- fgets(nodeLine,512,nfp);
- fputs(nodeLine,ofp);
- }
- }
- else if(command == 'A')
- {
- for(i = 0; i < counter; i++)
- {
- rotateCursor();
- fgets(nodeLine,512,dfp);
- fputs(nodeLine,ofp);
- }
- }
- else
- {
- message("Invalid nodediff command");
- return;
- }
- }
- fclose(dfp);
- fclose(nfp);
- fclose(ofp);
- if((ptr1 = strchr(outFile, '.')) != NULL)
- *ptr1 = '\0';
- strcat(outFile, extension);
- rename("templist", outFile);
- SetFileType(outFile,'TEXT');
- SetFileSignature(outFile,'TABY');
- InitCursor();
- message("New nodelist created!");
- }
-